﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using QuickGraph;

namespace www.coursera.org.Sample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
    

        public MainWindow()
        {
            try
            {
                InitializeComponent();


                DataContext = this;

                BidirectionalGraph<object, IEdge<object>> g = new BidirectionalGraph<object, IEdge<object>>();
                g.Clear();
                string fileName = "TextFile1.txt";
                char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
                int count = 0;

                using (StreamReader sr = new StreamReader("TestCases\\" + fileName))
                {
                    String line;
                    // Read and display lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null && count<4000)
                    {
                        string[] list = line.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
                        string v = list[0];
                        string w = list[1];
                        if (!g.ContainsVertex(v))
                        {
                            g.AddVertex(v);
                        }
                        if (!g.ContainsVertex(w))
                        {
                            g.AddVertex(w);
                        }

                        g.AddEdge(new Edge<object>(v, w));

                        count = count + 1;

                    }

                }

                var tempg = g.Clone();
                tempg.RemoveEdgeIf(p=>true);
                foreach (var e in g.Edges)
                {
                    var t=e.Source;
                    var s = e.Target;
                    tempg.AddEdge(new Edge<object>(s,t));



                }

                graphLayout.Graph = g;

            }
            catch (Exception e)
            {

                throw e;
            }
            

            


            
           

            
            

            
        }

        

        
    }
   

   
}
